﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using PerfAnalyzerLib;

namespace ArgumentManager
{
    /// <summary>
    ///This is a test class for ArgumentManagerTest and is intended
    ///to contain all ArgumentManagerTest Unit Tests
    ///</summary>
	[TestClass]
	public class ArgumentManagerTest
	{
		/// <summary>
		///A exception test for adding the same argument twice.
		///</summary>
		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void ArgumentManager_AddFlagArgumentException()
		{
			var target = new ArgumentManager();

			string name = "-argument";
			string description = "Test Description";
			target.AddFlagArgument(name, description);
			target.AddFlagArgument(name, description);
		}

		/// <summary>
		///Test Parse method.
		///</summary>
		[TestMethod]
		public void ArgumentManager_ParseTest()
		{
			// Add 2 parameters and parse them.

			ArgumentManager target = new ArgumentManager();

			var parameters = new List<string>();

			string param1 = "-param1";
			string param1Val = "param1Value";

			string flag1 = "flag1";

			target.AddValueKeyArgument(param1, typeof(string), false, "Param1 Description");
			target.AddFlagArgument(flag1, "Flag1 Description");

			parameters.Add(param1);
			parameters.Add(param1Val);
			parameters.Add(flag1);

			target.Parse(parameters.ToArray());
			Assert.AreEqual(param1Val, (string)target.Arguments[param1]);
			Assert.AreEqual(null, target.Arguments[flag1]);
		}
	}
}
